package org.example.sword2offer.primary;


/**
 * @author: lynn
 * @Descript: 二叉树的深度
 * 输入一棵二叉树，求该树的深度。从根结点到叶结点依次经过的结点（含根、叶结点）形成树的一条路径，最长路径的长度为树的深度
 * @date: 2021/3/18 21:26
 * @version: 1.0
 */
public class Q38_TreeDepth {
    public static void main(String[] args) {

    }

    private static int  getTreeDepth(TreeNode root){
        if (root==null){
            return 0;
        }
        return Math.max(getTreeDepth(root.left),getTreeDepth(root.right))+1;
    }

    private static class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        public  void TreeNode(int val){
            this.val=val;
        }
    }
}
